path = "F:\study\gospace\goweb\src\www\logs\conlose_log_2018-04-16.log"

import time
import json

def tail(f):
    f.seek(0, 2)
    while True:
        line = f.readline()
        if not line:
            time.sleep(0.1)
            continue
        yield line

# def grep(lines, searchtext):
#     for line in lines:
#         if searchtext in line:
#             yield line


flog = tail(open(path, encoding='utf-8'))
# pylines = grep(flog, 'python')
# for line in pylines:
#     print(line, )

for info in flog:
    if_dict = json.loads(info.split("|")[1])
    if if_dict.get("code", 400) != 200:
        print(if_dict)
